home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / docs / misc / ConcNews.lha / news / general.programming / comp.sys.amiga.programmer_5332_000010.msg < prev    next >
Encoding:
Text File  |  1994-11-27  |  3.4 KB  |  103 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: dd.chalmers.se!news.chalmers.se!sunic!pipex!howland.reston.ans.net!xlink.net!uni-heidelberg!rz.uni-karlsruhe.de!stepsun.uni-kl.de!uklirb!feck
  3. From: feck@informatik.uni-kl.de (Christoph Feck IRZ)
  4. Subject: Re: Text Editor: suggest some features you would like [LONG]
  5. Message-ID: <1994Feb1.154058@informatik.uni-kl.de>
  6. Sender: news@uklirb.informatik.uni-kl.de (Unix-News-System)
  7. Nntp-Posting-Host: uklirb.informatik.uni-kl.de
  8. Organization: University of Kaiserslautern, Germany
  9. References: <2hdn8n$o24@st-james.comp.vuw.ac.nz> <2hgvt9$14tt@msuinfo.cl.msu.edu> <DAST.94Jan26105934@pop.sth.frontec.se> <2ij1t8INNd7h@iraun1.ira.uka.de>
  10. Date: Tue, 1 Feb 1994 14:40:58 GMT
  11. Lines: 90
  12.  
  13. My (never completed) editor uses a double linked list of
  14. doubly buffer-gapped arrays with pointers and lenghts to
  15. pooled and multi buffer-gapped lines :)  Uh, sounds wired?
  16.  
  17. Ok, lemme explain:  (All from mind, I'm not here at my Amiga)
  18.  
  19. struct Text
  20. {
  21.     struct List blocks;
  22.     ...
  23. };
  24.  
  25. struct Block
  26. {
  27.     struct MinNode node;
  28.     word allocated;   /* size of the array */
  29.     word firstfree;   /* implies a gap at the and of the array */
  30.     word gap;         /* second, `floating' gap */
  31.     word gapsize;
  32.     struct Line *array;
  33. };
  34.  
  35.  
  36. array looks like this:
  37.  
  38. array -> +-------------+
  39.          | struct Line | 0    entry 0 always used (unless gap is 0)
  40.          +-------------+
  41.          | struct Line | 1
  42.          +-------------+
  43.          | struct ELine| 2    gap = 2
  44.          +-------------+
  45.          | (free)      | 3    gapsize = 2 (2..3)
  46.          +-------------+
  47.          | struct Line | 4    gap + gapsize = 4
  48.          +-------------+
  49.          | struct Line | 5
  50.          +-------------+
  51.          | struct ELine| 6    firstfree = 6
  52.          +-------------+
  53.          | (free)      | 7    allocated = 8 (0..7)
  54.          +-------------+
  55.  
  56. Emtpy array (can be removed during garbage collection):
  57.  
  58. array -> +-------------+
  59.          | struct ELine| 0    allocated = 1, gap = 0, gapsize = 0, firstfree = 0.
  60.          +-------------+
  61.  
  62. An array should not hold more than 200...1000 lines.  (depending on total no. of lines)
  63.  
  64. struct Line      (8 bytes, quite handy for scaled 020 indexing)
  65. {
  66.     char *string;   /* points to address into pool */
  67.     uword length;   /* 1...65535 chars in one line (including '\0' byte) */
  68.     uword flags;   /* misc flags, for display routines, garbage collectors, and folds */
  69. };
  70.  
  71. For ease of use, the ending Line in a block looks like this:
  72.  
  73. struct ELine
  74. {
  75.     char *null;   /* always NULL */
  76.     struct Line *next;  /* NULL, if no next line (EOT) */
  77. };
  78.  
  79. Using gaps avoids large block moves, when inserting/removing lines.
  80.  
  81.  
  82. Now the pools...  Pools are actually standard exec pools, like
  83. in Allocate/Deallocate.  Every string starts on a 8 byte boundary.
  84. Inserting characters requires reallocating a puddle only every 8
  85. chars.  The total overhead per line is about 14 bytes (average).
  86.  
  87. The routines are a bit complicated ;)  For example, to copy
  88. a selection to another text, the routine collects as much
  89. adjacent lines in a pool as possible and copies them using
  90. CopyMemQuick()
  91.  
  92. Moving to another position just requires re-linking and perhaps
  93. a bit sorting the struct Blocks.
  94.  
  95. More about buffer gaps can be read in the amazing book:
  96. "The Craft of Text Editing - Emacs for the Modern World"
  97.  
  98. Ciao,
  99. Christoph
  100.  
  101. 3k// Christoph Feck, TowerSystems
  102. \X/ Amiga - Intuition inside.
  103.